import { Component, inject, DestroyRef, OnInit } from '@angular/core';
import { DatePipe } from '@angular/common';
import { LouYuanService } from '../services/louyuan.service';
import { LouYuan } from '../models/louyuan.model';

@Component({
  selector: 'app-louyuan',
  imports: [DatePipe],
  templateUrl: './louyuan.component.html',
  styleUrl: './louyuan.component.css'
})
export class LouYuanComponent implements OnInit {
  private louyuanService: LouYuanService = inject(LouYuanService);
  private destroyRef = inject(DestroyRef);
  allLouYuan = this.louyuanService.allLouYuan;

  ngOnInit(): void {
    const subscription = this.louyuanService.getAllLouYuan().subscribe({
      next: (data) => {

      }
    })
    this.destroyRef.onDestroy(() => { subscription.unsubscribe(); });
  }

  editLouYuan(louYuan: LouYuan) {
    console.log('Editing LouYuan:', louYuan);
  }

  deleteLouYuan(louYuan: LouYuan) {
    console.log('Deleting LouYuan:', louYuan);
  }
}
